/**
 * 
 * 设置界面
 */
import GViewBase from "../../../Core/GView/GViewBase";
import { AudioMgr } from "../../../Core/Manager/AudioMgr";


const { ccclass, property } = cc._decorator;

@ccclass
export default class SetCtrl extends GViewBase {
    @property(cc.Slider)
    slider_music: cc.Slider = null;
    @property(cc.Slider)
    slider_effect: cc.Slider = null;

    @property(cc.Toggle)
    tog_mucic: cc.Toggle = null;

    @property(cc.Toggle)
    tog_sound: cc.Toggle = null;

    onGStart() {
        let music_volume = AudioMgr.Ins().getMusicVolume();
        this.slider_music.progress = music_volume;
        let effect_volume = AudioMgr.Ins().getEffectVolume();
        this.slider_effect.progress = effect_volume;

        this.tog_mucic.isChecked = music_volume>0.5;
        this.tog_sound.isChecked = effect_volume>0.5;
    }
    public onToggleMusci() {
        AudioMgr.Ins().setMusicVolume(this.tog_mucic.isChecked? 1 : 0);

    }
    public onToggleEffect() {
        AudioMgr.Ins().setEffectVolume(this.tog_sound.isChecked? 1 : 0);
    }

    public onSliderMusic(event: cc.Slider, customEventData) {
        AudioMgr.Ins().setMusicVolume(event.progress);
    }

    public onSliderEffect(event: cc.Slider, customEventData) {
        AudioMgr.Ins().setEffectVolume(event.progress);

    }
}
